// Copyright (C) 2011 YANG Hao (yangh2007@gmail.com). All rights reserved.
//
// This file is part of the (cute)octopus project.
//
// This file may be distributed and/or modified under the terms of the
// GNU General Public License version 2 as published by the Free Software
// Foundation.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// Author(s): YANG Hao

#ifndef OWINDOW_H
#define OWINDOW_H

#include <QMdiSubWindow>

#include "ostd.h"

class ODoc;

class OCTOPUS_EXPORT OWindow : public QMdiSubWindow
{
public:
	explicit OWindow(ODoc* doc, QWidget *parent = 0);
	~OWindow();

	inline ODoc* doc() const {return m_doc;}
	void updateFilePath();

protected:
	virtual bool eventFilter(QObject *obj, QEvent *ev);
	virtual void closeEvent(QCloseEvent *closeEvent);

private:
	ODoc* m_doc;
};	

template <typename T>
inline T* oDocOf(QWidget* w)
{
	OWindow* window = dynamic_cast<OWindow*>(w->parent());
	return window ? dynamic_cast<T*>(window->doc()) : 0;
}

#endif // OWINDOW_H
